package com.ronan.imserver.processor.business;

import com.ronan.common.entity.business.GameValue;
import com.ronan.common.entity.business.Ibus;

/**
 * FileName    : com.ronan.imserver.processor.business
 * Description : 具体业务的处理器
 *
 * @author : ronan
 * @version : 1.0
 * Create Date : 2021/3/17 14:53
 **/
public enum BusinessProcessorManager {

    GAMEVALUE(GameValue.class, new GameValueProcessor(), "GameValue处理器");

    private final Class<? extends Ibus> clazz;
    private final BusProcessor processor;
    private final String desc;

    BusinessProcessorManager(Class<? extends Ibus> clazz, BusProcessor processor, String desc) {
        this.clazz = clazz;
        this.processor = processor;
        this.desc = desc;
    }

    public static BusProcessor getProcessByClazz(Class<? extends Ibus> bus) {
        for (BusinessProcessorManager processorManager : BusinessProcessorManager.values()) {
            if (bus == processorManager.clazz) {
                return processorManager.processor;
            }
        }
        throw new RuntimeException("Not Found process, ibus : " + bus.getClass());
    }
}
